package com.ajl.wx.module.comment.controller;


import com.ajl.wx.beans.po.VideoCommentPO;
import com.ajl.wx.module.comment.service.impl.TbVideoCommentServiceImpl;
import com.ajl.wx.beans.vo.ResultApi;
import com.ajl.wx.utils.ResultApiUtil;
import com.ajl.wx.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HouXinLin
 * @since 2020-09-24
 */
@RestController
@RequestMapping("api/comment")
public class TbVideoCommentController {
    private Logger logger = LoggerFactory.getLogger(TbVideoCommentController.class);

    @Autowired
    TbVideoCommentServiceImpl commentService;

    @PostMapping("submit")
    public ResultApi submit(VideoCommentPO comment){
        if (StringUtils.isNull(comment.getCommentContent())){return ResultApiUtil.fail(-1,"","");}
        comment.setCommentTimer(LocalDateTime.now());
        comment.setDeleteFlag("0");
        return ResultApiUtil.success(Boolean.valueOf(commentService.save(comment)).toString(),"");
    }

    @PostMapping("list")
    public ResultApi submit(@RequestParam("id") int id){
        return ResultApiUtil.success("",commentService.listComment(id));
    }

}
